#include "DateIntervalUnitTest.h"
#include "assertions.h"
#include "Date.h"


namespace
{
	const int TEST_PARAMETR = 2;
}


void testGetYearDiff()
{
	DateIntervalBuilder builder;
	DateInterval twoYearInterval = builder.setYear(2).build();
	assertEquals<int>(::TEST_PARAMETR, twoYearInterval.getYearDifference());
}

void testGetMonthDiff()
{
	DateIntervalBuilder builder;
	DateInterval twoMonthInterval = builder.setMonth(2).build();
	assertEquals<int>(::TEST_PARAMETR, twoMonthInterval.getMonthDifference());
}

void testGetDayDiff()
{
	DateIntervalBuilder builder;
	DateInterval twoDayInterval = builder.setDay(2).build();
	assertEquals<int>(::TEST_PARAMETR, twoDayInterval.getDayDifference());
}

void testGetHourDiff()
{
	DateIntervalBuilder builder;
	DateInterval twoHourInterval = builder.setHour(2).build();
	assertEquals<int>(::TEST_PARAMETR, twoHourInterval.getHourDifference());
}

void testGetMinuteDiff()
{
	DateIntervalBuilder builder;
	DateInterval twoMinuteInterval = builder.setMinute(2).build();
	assertEquals<int>(::TEST_PARAMETR, twoMinuteInterval.getMinuteDifference());
}

void testGetSecondDiff()
{
	DateIntervalBuilder builder;
	DateInterval twoSecondInterval = builder.setSecond(2).build();
	assertEquals<int>(::TEST_PARAMETR, twoSecondInterval.getSecondDifference());
}

void testGetDateInterval()
{
	Date  firstDate(2011, Date::Mar, 9,  14, 38, 16);
	Date secondDate(2013, Date::Jan, 12, 12, 12, 45);
	DateInterval interval = firstDate.getInterval(secondDate);
	assertEquals<int>(2, interval.getYearDifference());
	assertEquals<int>(-2, interval.getMonthDifference());
	assertEquals<int>(3, interval.getDayDifference());
	assertEquals<int>(-2, interval.getHourDifference());
	assertEquals<int>(-26, interval.getMinuteDifference());
	assertEquals<int>(29, interval.getSecondDifference());
}

void dateIntervalTestSuite()
{
		testGetYearDiff();
		testGetMonthDiff();
		testGetDayDiff();
		testGetHourDiff();
		testGetMinuteDiff();
		testGetSecondDiff();
		testGetDateInterval();
}